package org.jmq.myblog.controller;

import org.jmq.myblog.pojo.ChangePw;
import org.jmq.myblog.service.UserService;
import org.jmq.myblog.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/sendCode")
    public ResponseResult sendCode(@RequestBody ChangePw changePw,HttpSession session){
        return userService.sendCode(changePw.getUseremail(),session);
    }

    @PostMapping("/checkCode")
    public ResponseResult checkCode(@RequestBody ChangePw changePw,HttpSession session){
        return userService.checkCode(changePw.getUseremail(),changePw.getCode(),changePw.getPassword(),session);
    }


}
